import mongoengine as db
from app.db import BaseDocument
from app.db.models.tasks import Warnings
from app.libs.enums import InspectionEventMarkerStatus, InspectionStrategySwitchStatus, InspectionStrategyIgnoreType


class ScanEventsInspection(BaseDocument):
    meta = {
        "collection": "scan_events_inspection",
        "strict": False
    }
    eventId = db.StringField(default="")
    warningId = db.StringField(default="")
    taskSessionId = db.StringField(default="")
    markerStatus = db.EnumField(InspectionEventMarkerStatus, default=InspectionEventMarkerStatus.IGNORE)
    remarks = db.StringField(default="")
    supportingImageIds = db.ListField(db.StringField())
    warningDetail = db.EmbeddedDocumentField(Warnings)
    foundAt = db.DateTimeField()
    createdAt = db.DateTimeField()
    updatedAt = db.DateTimeField()


class IgnoreStrategies(BaseDocument):
    meta = {
        "collection": "ignore_strategies",
        "strict": False
    }
    url = db.StringField()
    key = db.StringField()
    ignoreType = db.EnumField(InspectionStrategyIgnoreType, default=InspectionStrategyIgnoreType.FALSE_POSITIVE)
    remarks = db.StringField()
    switchStatus = db.EnumField(InspectionStrategySwitchStatus, default=InspectionStrategySwitchStatus.OPEN)
    createdAt = db.DateTimeField()
    updatedAt = db.DateTimeField()


class SupportingImages(BaseDocument):
    meta = {
        "collection": "supporting_images",
        "strict": False
    }
    eventId = db.StringField()
    unique = db.StringField()
    content = db.BinaryField()
    createdAt = db.DateTimeField()
    updatedAt = db.DateTimeField()
